package ru.gerunn.regex;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) throws IOException {
		FileInputStream fis = new FileInputStream("/home/ge/local/temp/ETD-WARN-2012-12-05_08.46.43-09.23.57.Log4j.log");
		FileChannel fc = fis.getChannel();
		ByteBuffer bbuf = fc.map(FileChannel.MapMode.READ_ONLY, 0, (int) fc.size());
		CharBuffer cbuf = Charset.forName("utf-8").newDecoder().decode(bbuf);

		Pattern pattern = Pattern.compile("^(.*),\\d\\d\\d WARN \\[net\\.ttddyy\\.dsproxy\\.listener\\.CommonsQueryLoggingListener] - ;(\\d+) ;.*; \\[(.*)\\] ;(.*?)$", Pattern.DOTALL);
		Matcher matcher = pattern.matcher(cbuf);

		while (matcher.find()) {
			System.out.println("[" + matcher.group(4) + "]");
			System.in.read();
		}

	}

}
